<!DOCTYPE html>
<html lang = "en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width-device width,user scalable-no,initial scale=1.0,maximum-scale=l.0,minimum scale=l.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Title</title>

    <script src="js/jquery.min.js"></script>

    <script>

        async function show(){  //实际async的用途是标识,让可以暂停;普通的函数不可以暂停
            console.log('start...');
            //进行等待(异步)操作

            try{
                let res = await $.ajax({url: 'http://192.1681.1.90:28080/arrTest.txt',dataType: 'json'});
                alert(res);
            }catch (e) {
                alert('failed!  ');
                console.log('show() failed: ',e)
            }

            //补充:async实际会将函数进行拆分,await之前为一个函数,await单独一个,在执行await中的ajax时与promise一样会.then,在成功处再执行await之后的代码
        }

        let res2 = show();
        console.log(res2)    //返回的结果为promise对象




    </script>
</head>


<body>
<script type="text/javascript">

</script>



</body>
</html>



